<template>
  <div class="app-container flex-col minH">
    <div class="topline w100p bgwhite ptb20 radius10 pl10 pr20 justify-between">
      <div>
        <el-input v-model="uid" style="width: 280px" placeholder="搜尋用戶訊息ID..." :prefix-icon="Search" class="search" />
        <el-input v-model="fromid" style="width: 280px" placeholder="搜尋來源人訊息ID..." :prefix-icon="Search" class="search ml10" />

      </div>
      <div>
        <el-button class="btn2" @click="getRelationList()">查詢</el-button>
        <el-button class="btn1" @click="reset()">重置</el-button>
      </div>
    </div>
    <div class="mt15 radius10 hidden pb15 flex1 bgwhite  flex-col w100p">
      <div class="flex1 w100p ">
        <el-table :data="tableData" style="width: 100%" cell-class-name="tbcell" header-cell-class-name="hdcell">

          <el-table-column prop="user" label="用戶訊息" min-width="300">
            <template #default="scope">
              {{ scope.row.user.phone }}(ID:{{ scope.row.user.id }})
            </template>
          </el-table-column>
          <el-table-column prop="fromuser" label="來源人訊息" min-width="300">
            <template #default="scope">
              {{ scope.row.fromuser.phone }}(ID:{{ scope.row.fromuser.id }})
            </template>
          </el-table-column>
          <el-table-column prop="profit" label="佣金" min-width="300" />
          <el-table-column prop="created_at" label="創建時間" min-width="300" sortable />
        </el-table>
      </div>

    </div>
    <el-dialog v-model="dialogTableVisible" title="邀请人列表">
      <div class="plr20 justify-between ptb20">
        <div>
          <el-time-picker v-model="value2" placeholder="開始時間" />
          <span class="plr10">-</span>
          <el-time-picker v-model="value2" placeholder="結束時間" />
        </div>
        <div>
          <el-button class="btn2">查詢</el-button>
          <el-button class="btn1">重置</el-button>
        </div>

      </div>
      <el-table :data="tableData" cell-class-name="dialogtbcell" header-cell-class-name="dialoghdcell">
        <el-table-column property="date" label="用戶訊息" width="200" />
        <el-table-column property="name" label="用戶昵稱" width="200" />
        <el-table-column property="address" label="用戶頭像">
          <template #default>
            <el-avatar shape="square" :size="50" :fit="'cover'" :src="url" />
          </template>

        </el-table-column>
        <el-table-column property="address" label="邀請時間" />

      </el-table>
      <div class="  plr20 justify-between mt20">
        <div style="flex:1;">總共10條</div>
        <el-pagination v-model:current-page="currentPage" prev-text="上一頁" next-text="下一頁" :default-page-size="15" :small="small" :disabled="disabled" :background="true" layout="prev, pager, next, jumper" :total="1000" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { Search } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router';
import { relationList } from '@/api/invite.js'
onMounted(() => {
  getRelationList()
})
const getRelationList = () => {
  relationList({
    page: currentPage.value,
    per_page: 1000,
    uid: uid.value,
    fromid: fromid.value
  }).then((res) => {
    console.log('系统参数列表', res)
    tableData.value = res.data.data
    total.value = res.data.total
  })
}
const reset = () => {
  uid.value = ''
  fromid.value = ''
  getRelationList()
}
const uid = ref('')
const fromid = ref('')

const dialogTableVisible = ref(false)
const url = 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
const tableData = ref([])
const tableRowClassName = () => {
  return 'tbrow'
}
const currentPage = ref(1)
const total = ref(0)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
}
const router = useRouter()
const toAdd = () => {
  console.log(router)
  router.push({ path: 'addNotice' })
}
const edit = (type) => {
  router.push({ path: 'edit' })
}
</script>

<style lang="scss" scoped>
.search {
  overflow: hidden;
  border-radius: 10px !important;
  // padding: 5px 0px;
}
</style>
<style></style>
